<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>

<script>
  let hd = `
    https://www.houdunren.com
    http://houdunwang.com
    https://hdcms.com
    `;

  // ?表示前一个字符可有可无，当你的问号在原子组中就表示原子组不可用
  let reg = /https?:\/\/((?:\w+\.)?\w+\.(com|org|cn))/gi;
  let urls = [];

  while ((res = reg.exec(hd))) {
    urls.push(res[1]);
  }
  console.log(urls);
</script>
